package com.lry;


import com.lry.read.ReadAll;
import com.lry.write.WriteAll;
import com.lry.write.WriteOne;

import java.util.concurrent.CompletableFuture;

public class Start {

    public static void main(String[] args) throws Exception {
        Node node1 = new Node("node1");
//        node1.error = true;
        Node node2 = new Node("node2");
        Node node3 = new Node("node3");
        NodeManager nodeManager = new NodeManager(new ReadAll(),new WriteAll(),node1,node2,node3);

        for(int i=0;i<10;i++){
            CompletableFuture.runAsync(()->{
                System.out.println(nodeManager.put("k", "v"));
            });
        }

        for(int i=0;i<10;i++){
            CompletableFuture.runAsync(()-> {
                System.out.println(nodeManager.get("k"));
            });
        }

        System.in.read();
    }

}
